import { name } from '../../package.json'

const TokenKey = (window.__POWERED_BY_QIANKUN__ ? '' : `${name}-`) + 'token'
const UserInfoKey = (window.__POWERED_BY_QIANKUN__ ? '' : `${name}-`) + 'user-info'

export function getToken () {
  return localStorage.getItem(TokenKey)
}

export function setToken (token) {
  return localStorage.setItem(TokenKey, token)
}

export function removeToken () {
  return localStorage.removeItem(TokenKey)
}

export function setUserInfo(userInfo) {
  return localStorage.setItem(UserInfoKey, JSON.stringify(userInfo))
}

export function getUserInfo() {
  return JSON.parse(localStorage.getItem(UserInfoKey)) || null
}

export function removeUserInfo() {
  return localStorage.removeItem(UserInfoKey)
}
